//
//  DateCell.m
//  geiTA
//
//  Created by 曲丹阳 on 14-11-19.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DateCell.h"
#import "DateModel.h"
@implementation DateCell
- (void)dealloc
{
    [_photoImageView release];
    [_nameLabel release];
    [_remindLabel release];
    [_countdownLabel release];
    [_promptImageView release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if ( self =[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.photoImageView = [[UIImageView alloc]initWithFrame:CGRectZero];
        [self addSubview:_photoImageView];
        
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        [self addSubview:_nameLabel];
        
        self.remindLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        [self addSubview:_remindLabel];
        
        self.countdownLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        [self addSubview:_countdownLabel];
        
        self.promptImageView =[[UIImageView alloc]initWithFrame:CGRectZero];
        [self addSubview:_promptImageView];
        
        [self addObserver:self forKeyPath:@"model" options:NSKeyValueObservingOptionNew context:nil];
        
    }
    return self;

}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"model"]) {
        //头像没写
        self.nameLabel.text = self.model.name;
        self.remindLabel.text =self.model.remind;
        self.countdownLabel.text = self.model.countd;
    }
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [_photoImageView setFrame:CGRectMake(10, 10, self.frame.size.height - 20, self.frame.size.height - 20)];
    [_photoImageView setBackgroundColor:[UIColor blueColor]];
    
    [_nameLabel setFrame:CGRectMake(_photoImageView.frame.origin.x + _photoImageView.frame.size.width + 10, 10, self.frame.size.width/5, _photoImageView.frame.size.height /2 - 5)];
    [_nameLabel setBackgroundColor:[UIColor redColor]];
    
    [_promptImageView setFrame:CGRectMake(_photoImageView.frame.origin.x + _photoImageView.frame.size.width + 10 , _nameLabel.frame.origin.y + _nameLabel.frame.size.height + 5, _photoImageView.frame.size.height /2, _photoImageView.frame.size.height /2 - 5)];
    [_promptImageView setBackgroundColor:[UIColor yellowColor]];
    
    [_remindLabel setFrame:CGRectMake(_promptImageView.frame.origin.x + _promptImageView.frame.size.width, _nameLabel.frame.origin.y + _nameLabel.frame.size.height + 5, self.frame.size.width/5, _photoImageView.frame.size.height /2 - 5)];
    [_remindLabel setBackgroundColor:[UIColor redColor]];
    
    [_countdownLabel setFrame:CGRectMake(self.frame.size.width/5 *3, 10, self.frame.size.width/5 *2, self.frame.size.height-20)];
    [_countdownLabel setBackgroundColor:[UIColor redColor]];
    
    
    
    
}


@end
